package cz.muni.fi.heathrow.servicesImpl;

import cz.muni.fi.heathrow.exceptions.ServiceFailureException;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

public class ServicesInterceptor implements MethodInterceptor
{

    @Override
    public Object invoke(MethodInvocation methodInvocation) throws Throwable
    {

        try
        {
            Object result = methodInvocation.proceed();

            return result;

        } catch (Exception e)
        {
            throw new ServiceFailureException("Method " + methodInvocation.getMethod().getName() + " failed: " + e.getMessage(), e);
        }
    }
}
